<template>
  <view class="content" >
	<uniPopup background-color="rgba(255,255,255,0)" ref="inputDialog"  type="dialog" >
      <div class="mboxContent">
        <div class="main">
          <div class="mainText">确定删除吗?</div>
          <div class="explain">删除后无法恢复该数据</div>
        </div>
      
       
        <div class="btn">
          <div class="fail btnItem" @click="toClose">取消</div>
          <div class="success btnItem" @click="toright">确认</div>

        </div>
      </div>
		
			</uniPopup>
  </view>
</template>

<script>
  import  {deleteDefect,} from '@/utils/http'
import uniPopup from "@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue";
export default {
    components:{
    uniPopup
  },
  props: {
    titles: {
      type: String,
    },
    type:{
type:String,

    },
    datas: {
      type: Array,
    },
    ids:{
      type:String,
    },
    isOpen: {
      type: Boolean,
    },
    forms:{
      type:Object,
    }
  },
  data() {
    return {
      title: "",
    
    };
  },

  onLoad() {},
  methods: {
    toright(){

      if(this.datas.length >0){

        var json={
          ids:this.datas
        }
        console.log()
        deleteDefect(json).then(res=>{
        if(res.code == '0'){
          uni.showToast({
								title:'操作成功',
								duration:1500
							})
              if(uni.getStorageSync('userInfo').role == 'inspection'){
                    uni.reLaunch({
 url:'/pages/order/index'
})
                  }else  if(uni.getStorageSync('userInfo').role == 'admin' ||uni.getStorageSync('userInfo').role == 'administrator' ){
                    uni.reLaunch({
 url:'/pages/order/managerIndex'
})
                  }
              this.$parent.checkedArr=[]
              this.$parent.allChecked=false
              this.toClose()
        }else{
          uni.showToast({
								icon:'none',

								title:res.msg,
								duration:1500
							}) 
        }
      })
     
      }else {
        var json={
          ids:[],
          ...this.forms
        }
        console.log()
        deleteDefect(json).then(res=>{
        if(res.code == '0'){
          uni.showToast({
								title:'操作成功',
								duration:1500
							})
              if(uni.getStorageSync('userInfo').role == 'inspection'){
                    uni.reLaunch({
 url:'/pages/order/index'
})
                  }else  if(uni.getStorageSync('userInfo').role == 'admin' || uni.getStorageSync('userInfo').role == 'administrator'){
                    uni.reLaunch({
 url:'/pages/order/managerIndex'
})
                  }
              this.$parent.checkedArr=[]
              this.$parent.allChecked=false
              this.toClose()
        }else{
          uni.showToast({
								icon:'none',

								title:res.msg,
								duration:1500
							}) 
        }
      })
      }

    },
    toClose(){
      this.$emit('closeAll',true)
      this.$refs.inputDialog.close()
    }
   
   
  },
};
</script>

<style scoped >

.mboxContent{
  text-align: center;
 
  background: white;
  box-sizing: content-box;
  /* padding:24px; */
  width: 540rpx;
  border-radius: 20px;

}
.main{
  min-height: 274rpx;
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
}
.mainText{
  font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: bold;
font-size: 34rpx;
color: #262626;
font-style: normal;
}
.explain{
  font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: bold;
font-size: 22rpx;
color: #808080;
font-style: normal;
}
.btn{
  width: 100%;
  display: flex;
  box-sizing: border-box;
  padding:18rpx 0;
display: flex;
border-top: 2rpx solid #CBCBCB;
}
.fail{
  position: relative;

}
.fail::before{
  content: '';
  position: absolute;
  display: inline-block;
  width: 2rpx;
  background:  #CBCBCB;
  height: 86rpx;
    top: -20rpx;
    right: 0;
}
.btnItem{
  text-align: center;
    width: 49%;
    font-family: Source Han Sans CN, Source Han Sans CN;
font-weight: bold;
font-size: 32rpx;
color: #0098C9;
font-style: normal;
  }



</style>
